package com.sxw.page;


import com.sxw.web.ReactiveRequestContextHolder;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.MultiValueMap;

/**
 * 表格数据处理
 * 
 * @author ruoyi
 */
public class TableSupport
{
    /**
     * 当前记录起始索引
     */
    public static final String PAGE_NUM = "pageNum";

    /**
     * 每页显示记录数
     */
    public static final String PAGE_SIZE = "pageSize";

    /**
     * 排序列
     */
    public static final String ORDER_BY_COLUMN = "orderByColumn";

    /**
     * 排序的方向 "desc" 或者 "asc".
     */
    public static final String IS_ASC = "isAsc";

    /**
     * 分页参数合理化
     */
    public static final String REASONABLE = "reasonable";

    /**
     * 封装分页对象
     */
    public static PageDomain getPageDomain()
    {
        PageDomain pageDomain = new PageDomain();
        String ss = ReactiveRequestContextHolder.getRequest().map(i->{
            MultiValueMap<String, String> z = i.getQueryParams();
            z.forEach((key,value)-> {
                System.out.println(key);
                System.out.println(value);
            });
            return "sss";
        }).block();
//        pageDomain.setPageNum(Convert.toInt(RequestUtils.getCurrentRequestPath(PAGE_NUM).contextWrite(), 1));
//        pageDomain.setPageSize(Convert.toInt(RequestUtils.getCurrentRequestPath(PAGE_SIZE).block(), 10));
//        pageDomain.setOrderByColumn((String) RequestUtils.getCurrentRequestPath(ORDER_BY_COLUMN).block());
//        pageDomain.setIsAsc((String) RequestUtils.getCurrentRequestPath(IS_ASC).block());
//        pageDomain.setReasonable((Boolean) RequestUtils.getCurrentRequestPath(REASONABLE).block());
        return pageDomain;
    }

    public static PageDomain buildPageRequest()
    {
        return getPageDomain();
    }
}
